package com.briup.es.web.controller;

import com.briup.es.config.response.Result;
import com.briup.es.service.UploadService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

@Api(tags = "文件上传模块")
@RestController
public class UploadController {

    @Resource
    private UploadService uploadService;

    @ApiOperation("上传文件")
    @PostMapping("/upload")
    public Result<?> upload(@RequestPart MultipartFile file) {
        String url = uploadService.upload(file);
        return Result.success(url)
                .apply("上传成功");
    }
}
